1. Field of the Invention
The present invention is directed toward the field of object oriented programming, and more specifically to methods, apparatus, and computer readable medium for enhancing declarative programming in an object-oriented system.
2. Art Background
An object oriented approach to programming provides many advantages over traditional procedural programming approaches. For example, an object oriented approach permits code reuse through inheritance and modularity through encapsulation. There are many views as to what concepts define object oriented programming, and there are many terms and definitions for defining these concepts. In general, objects incorporate procedures, also called methods or operations, and data, also called attributes or properties. Objects are instantiated from and described by structures known as classes or types. For purposes of nomenclature, the object oriented programming environment described herein defines classes as types. A type is a general abstract specification, and an object instantiated from a type is a specific concrete instance of the type.
A type consists of an interface and an implementation. The interface comprises variables and function declarations, wherein the variables represent the attributes of the type, and the function declarations specify methods for manipulating those attributes as well as performing other operations. The declaration specifies the name, return type, and argument, known collectively as the signature. The implementation refers to the actual code that implements the methods specified in the interface. Types may consist of abstract types or implementation types. Objects are not instantiated from abstract types. Instead, objects are instantiated from an implementation type.
In general, objects communicate through message passing mechanisms. An object, known as a client object, may call a method of another object. A client object invokes a method of another object by accessing the object via the defined interfaces. Thus, to invoke a method in an object or to query an object, the client object requires knowledge of the signatures of the methods in the interface of the target object. The client object calls the methods and passes the appropriate parameters. For example, to obtain the value of an attribute in an object, a client object calls a method, via an interface, to obtain the value.
The concept of isolating the implementation of the methods and attributes within an object is known as encapsulation. Encapsulation is a powerful feature of object oriented systems because it separates the external part of an object (e.g., the part exposed to the objects user) from the internal part (e.g., the structure and implementation). Therefore, encapsulation permits changing the object implementation without affecting the interaction with other functions or objects as long as the interface does not change.
Object oriented languages, such as the C++ programming language, permit the creation of special types via inheritance. In general, inheritance is a mechanism for passing attributes and methods from a parent or base type to one or more child or derived types. Inheritance permits code reuse because interfaces and implementations need not be duplicated in the child type. Instead, the interfaces and implementations may be incorporated in any child type through reference of the parent or base type.
Just as there are many different concepts that define object oriented programming, there are also many different and diverse object oriented systems. One example of how object oriented systems differ is in methods of code reuse.
As discussed above, object oriented programming techniques permit code reuse through reuse of objects. However, in certain circumstances, a programmer may desire to alter an existing object without creating an entirely new object. Instead of creating a new and distinct object, current object oriented programming techniques permit a program developer to "subclass" the object. Generally, subclassing techniques permit a developer to generate a new method on a subclass, such that the new subclass has a method different from a method in the original class. Redirecting a call from an old method of a class to a new method in a subclass is known as method overriding.
Typically, object interfaces include a plurality of pointers that point to a table of pointers, known as a virtual table (v_table.) In general, subclassing techniques involve changing the pointer in an object's v_table to point to a new function or method. When the method on that object is called, the v_table directs the call to the new function or method. To implement subclassing, a program developer requires access to the object's metadata to modify the object's v_table. However, a software developer does not always have access to an object's metadata. For example, if the software developer is using an object that consists of C++ compiled code, then the developer does not have access to the object's v_table, and the subclassing technique is not available to augment or change the methods on the object. The software developer also requires knowledge of the signatures of all of the methods on the object. The location of the v_table is compiler dependent, and thus is not readily known from objects compiled from different compilers. In addition, to alter the v_table, the software developer requires knowledge of the location of the object's v_table. Furthermore, the subclassing technique requires re-compiling the code, which in turn requires shutting down the application and reloading both the new and old code. Thus, it is desirable to provide a technique to permit augmentation of a method, to alter the behavior of an object, even though the source metadata is not available to the software developer.
There are various ways to approach application program development in an object oriented programming environment. A declarative approach permits an application developer to express declarations by coding these declarations into the system. Although the declarative approach works best for certain tasks, such as adding features to an existing system, some functions cannot be expressed in a declarative manner.
Other systems permit application development through traditional code development cycles. For example, programming languages, such as third generation languages (3GL), may be used to specify functionality through development of class objects. This approach to application development requires compiling code to generate executable run time code. Although the 3GL compiled approach is perhaps the most powerful approach, it is also the most resource intensive and time consuming approach.
A third approach to application development in an object oriented system is through use of fourth generation languages (4GL). The 4GL approach permits adding functionality to currently existing systems. Although each approach has benefits, it is desirable to permit integration of all three styles of application building.
To support application program development, a number of tools and editors are used. One such tool permits diagramming events to model an application program. Although these diagrammers provide a starting point for code development, they do not adequately capture how objects are affected as the objects progress through the system. The modeling tools do not describe the structure and behavior of the objects. For example, prior art systems capture information about the system so that the user may query to determine the relationship between objects, and how these objects move through the system. Although these queries are informative, they do not provide a means to enforce, through declarations, this relational information. Therefore, it is desirable to provide an object oriented system that enforces declarations to effect the relationships among objects in the system.